//
//  ZCFDCreateClassTableView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/22.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "ZCFDCreateClassTableView.h"

@implementation ZCFDCreateClassTableView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    if ([super initWithFrame:frame style:style]) {
        _dataArray = [NSMutableArray new];
       [self registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        self.delegate = self;
        self.dataSource  =self;
    }
    return self;
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return _dataArray.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]init];
    return view;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.font = [UIFont systemFontOfSize:14];
    if (_type == 1) {
        FenXiaoZhuJiaoModel *model = _dataArray[indexPath.row];
        cell.textLabel.text = model.name;
    }else if (_type == 2){
        FuDaoLeiXingObject *model = _dataArray[indexPath.row];
        cell.textLabel.text = model.name;
    }else if (_type == 3){
        cell.textLabel.text = _dataArray[indexPath.row];
    }else if (_type == 4){
        SYKaoShiModel *model = _dataArray[indexPath.row];
        cell.textLabel.text = model.title;
    }else if (_type == 5){
        NSDictionary *dic = _dataArray[indexPath.row];
        cell.textLabel.text = dic[@"name"];

    } else {
        cell.textLabel.text = @"辅导老师";
    }
    cell.textLabel.textColor = TITLECOLOR;
    cell.selectedBackgroundView = [self backV];
    cell.textLabel.highlightedTextColor = [UIColor whiteColor];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    self.block(indexPath,self.type);
    [self removeFromSuperview];
}
- (UIView *)backV{
    UIView *back = [[UIView alloc]init];
    back.backgroundColor = SELECTEDCOLOR;
    return back;
}
@end
